var clickUtils = require("../../utils/clickUtils");
var randomUtils = require("../../utils/randomUtils");
var textUtils = require("../../utils/textUtils");
var ocrUtils = require("../../utils/ocrUtils");
var inTask = require("./inTask");
var Action = require("../../base/Action");
var aTreasure = new Action("宝箱", {});
aTreasure.exec = function () {
  var contents = ["点击领金币", "点击领现金", "点我必得"];
  var TextUI = textUtils.existsOneTextStartsWith(contents);
  if (TextUI) {
    clickUtils.clickTextUI(TextUI);
    sleep(randomUtils.getRandom(2.5, 4, 1000));
    inTask.init();
    return true;
  }
  var TextOCR = ocrUtils.captureExistsOneText(contents);
  if (TextOCR) {
    clickUtils.clickTextOCR(TextOCR);
    sleep(randomUtils.getRandom(2.5, 4, 1000));
    inTask.init();
    return true;
  }
};
module.exports = aTreasure;
